from flask import Blueprint, g, redirect
from info.utils.commons import user_login_data

admin_blue = Blueprint('admin_blue', __name__, url_prefix='/admin')

from . import views


@admin_blue.before_request
@user_login_data
def admin_requred():
    """
    请求钩子
    使每一个请求后台的url都先执行这个钩子，以判断是否是管理员
    :return:
    """
    user = g.user
    if not user:
        return redirect('/')
